home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 151-175 / scopedisk157 / joylib / joydemo.c < prev    next >
C/C++ Source or Header  |  1995-03-19  |  1KB  |  58 lines

  1. /* Demo for joystick library (link version) */
  2. /* for Lettuce C */
  3. /* written by Olli */
  4.  
  5. #include <proto/intuition.h>
  6. #include <proto/graphics.h>
  7. #include <proto/exec.h>
  8. #include <joystick.h>
  9.  
  10. struct NewWindow nw={
  11.     20,20,240,45,
  12.     3,2,
  13.     CLOSEWINDOW,
  14.     RMBTRAP|WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE,
  15.     0,0,"JoyLib DEMO",0,0,
  16.     0,0,0,0,
  17.     WBENCHSCREEN};
  18.  
  19. struct IntuitionBase *IntuitionBase;
  20. struct GfxBase *GfxBase;
  21. struct RastPort *rp;
  22.  
  23. #define print(x,y,s) Move(rp,x,y);Text(rp,s,4)
  24.  
  25. void printjoy(int num)
  26. {
  27.     int v=(num)?joy1():joy0();
  28.     int x=(num)?125:5;
  29.  
  30.     print(x,30,(v&JOY_LEFT)?"LEFT":"    ");
  31.     print(x+70,30,(v&JOY_RIGHT)?"RIGT":"    ");
  32.     print(x+35,20,(v&JOY_UP)?" UP ":"    ");
  33.     print(x+35,40,(v&JOY_DOWN)?"DOWN":"    ");
  34.     print(x+35,30,(v&JOY_FIRE)?"FIRE":"    ");
  35. }
  36.  
  37. int _main(void)
  38. {
  39.     struct Window *w;
  40.  
  41.     IntuitionBase=OldOpenLibrary("intuition.library");
  42.     GfxBase=OldOpenLibrary("graphics.library");
  43.     if(!(w=OpenWindow(&nw))) goto xit;
  44.     rp=w->RPort;
  45.     SetAPen(rp,3);
  46.     SetBPen(rp,0);
  47.     SetDrMd(rp,JAM2);
  48.     while(!GetMsg(w->UserPort)) {
  49.     printjoy(0);
  50.     printjoy(1);
  51.     WaitTOF();
  52.     }
  53.     CloseWindow(w);
  54. xit:
  55.     return(0);
  56. }
  57.  
  58.